home *** CD-ROM | disk | FTP | other *** search
- Path: transfer.stratus.com!usenet
- From: matt_boutin@vos.stratus.com
- Newsgroups: comp.lang.c++
- Subject: Newbie Template Question
- Date: 7 Jan 1996 02:30:36 GMT
- Organization: Stratus Computer Inc, Marlboro MA
- Message-ID: <4cnb8c$qna@transfer.stratus.com>
- NNTP-Posting-Host: turin_h.hqsl.stratus.com
-
- I'm new to templates and have some questions on sytax. This is
- a school project. A chunk of code was given to us and we are
- supposed to finish it. The code is a map and map iterator template
- class. The questions that I have are for the map class. Here's the
- code with questions --
-
- template <class K, class V>
- class map
- {
- friend class MapIter<K,V>;
- public:
- Map() : i_defkey(0), i_defval(0) {init();}
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- // This will act as the void constructor right??
-
- ~Map() {delete i_headp; i_headp= 0;}
-
- // stuff omitted
-
- private:
-
- Map(const Map<K,V>&);
- //^^^^^^^^^^^^^^^^^^^
- // Teach says we don't need a copy constructor
- // this looks like a copy constructor to me.
- // Is it a copy constructor or can this be used as
- // the object constructor.
- // stuff omitted
-
- MapPair<K,V> *i_headp;
- MapPair<K,V> *i_currentp;
-
- const K i_defkey;
- V i_defval;
- }
-
- My question is:
- What would the constructor code look like.
- Having two values in the arg list is throwing me off.
- If the underlined segment above is the object constructor.
- forward declaration, what would the implementation look like.
-
- Any help would be greatly appreciated..
- MB
-
-
-
-
-